package net.wangds.auth.module;

public enum PrivilegeActionEnum {

    REJECT(0), ACCESS(1), CREATE(0x2), UPDATE(0x4),
    REMOVE(0x8), ALL(0xF), NOT_REMOVE(0x7),

    GRANT_ACCESS(0x10), GRANT_CREATE(0x20), GRANT_UPDATE(0x40),
    GRANT_REMOVE(0x80), GRANT_ALL(0xF0), GRANT_NOT_REMOVE(0x70),

    ALL_GRANT_ALL(0xFF)
    ;

    private int val;

    PrivilegeActionEnum(int val){
        this.val = val;
    }


    public static boolean havePrivilege(int priv, PrivilegeActionEnum test){
        return (Math.max(0,Math.min(priv, 0xFF))&test.val)>0;
    }


    public int toVal(){
        return val;
    }


}
